-
Notifications
You must be signed in to change notification settings - Fork 13.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Scale manual control setpoint up/down stick -1 to 1 #15949
Conversation
418388c
to
200a5ef
Compare
Reminder for myself to rebase on https://github.com/Auterion/PX4_firmware_private/pull/661 like discussed. EDIT: ✔️ |
5611a84
to
2aa4edd
Compare
2aa4edd
to
4f2c2f3
Compare
|
4f2c2f3
to
42f3966
Compare
This issue has been automatically marked as stale because it has not had recent activity. Thank you for your contributions. |
42f3966
to
131034a
Compare
I agree with you on this point. Seems a bit dangerous (error prone) that we are re-interpreting these manual controls everywhere they are used. |
I rebased this pr on main and after investigating carefully I suggest using roll, pitch, yaw, and throttle for the naming of the axes because:
The only two disadvantages I see are:
For the revamping of the Stick class to adapt and be reusable everywhere I suggest to do a follow-up pull request since this one is about the uORB interface. |
@junwoo091400 Thanks a lot for your review, additional thoughts and suggestions. Your feedback is highly appreciated just slightly on the verbose side 😇
I know. The big problem is solving backward compatibility on all sides e.g. QGC, MAVLink to an ambiguous definition that was misused in various out-of-range or other "fits the case" solutions. I explicitly wanted this pr to only solve the PX4 autopilot side and care about MAVLink and QGC in the next step. |
92510c6
to
1d18689
Compare
I had to rebase on #20647 and #20537 nothing complicated. After the feedback from yesterday's dev call I found a good solution for the backward compatibility: I do the same as before but not adjusting the throttle trim parameter. That solves the problem of having an adapted parameter when downgrading but also makes sure that it all works like expected with the default calibration everyone gets through QGC. So the door is open for a new calibration and phasing out the old one. I tested this again on hardware just to be sure. Also note that even though FMUv5x overflows this pr saves ~230bytes but main is overflowing more than that. In my eyes this is now good to go 🎉 |
Ah that's such a good idea! (Took me 10 seconds to understand though haha) Changing the run-time applied trim value, and not modifying the parameter value itself is an elegant solution 👍 I guess we should get the QGC PR in quickly! If you have a QGC dev environment, could you test on a real vehicle with real RC tx/rx whether the QGC PR: mavlink/qgroundcontrol#10497 works as expected (Set Trim to mid-value, not min)? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Forgot to formally put in my review, this is a great change! 😉
@junwoo091400 Thanks for your review!
I think we shouldn't over-hurry but rather avoid mistakes that could lead to user problems.
I currently don't sorry. But as I wrote in mavlink/qgroundcontrol#10497 (comment) we need to be careful. I'd guess with that pr the trim value doesn't necessarily get set to the middle but to where the throttle stick is at the beginning of the calibration which would be not deterministic and often at the bottom. Also think about the case where someone uses the latest QGC including that change but PX4 1.13 or main from yesterday. It would result in a configuration making half of the stick not work anymore for no reason. Let's go through it cleanly on the QGC side. |
To be consistent with all other axes of stick input and avoid future rescaling confusion. Note: for the MAVLink message 69 MANUAL_CONTROL it's using the full range according to the message specs now [-1000,1000].
In review it was requested to have a different name for manual_control_setpoint.z because of the adjusted range. I started to investigate what naming is most intuitive and found that most people recognize the stick axes as roll, pitch, yaw, throttle. It comes at no surprise because other autopilots and APIs seem to share this convention. While changing the code I realized that even within the code base the axes are usually assigned to a variable with that name or have comments next to the assignment clarifying the axes using these names.
This is fully backwards compatible: If the throttle trim is set to the minimum then it's the legacy calibration and gets interpreted such that there is no trim and behavior remains as before. If the trim is set to a different value than the minimum then it gets used like with all other channels which was unsupported before.
1d18689
to
3835c51
Compare
Yayyyy thanks for this @MaEtUgR !! |
# Stick positions [-1,1] | ||
# on a common RC mode 1/2/3/4 remote/joystick the stick deflection: -1 is down/left, 1 is up/right | ||
# Note: QGC sends throttle/z in range [0,1000] - [0,1]. The MAVLink input conversion [0,1] to [-1,1] is at the moment kept backwards compatible. | ||
# Positive values are generally used for: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Previously the mappings were vehicle and flight mode agnostic. An MC vehicle in position mode does not roll or pitch - it move forward or left-right. So you've made this very unintuitive except for fixed wing vehicles.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Previously the mappings were vehicle and flight mode agnostic.
I do not agree, previously the naming according to the cartesian coordinate system's axes x
, y
, z
only fully made sense for multirotor position mode where the values moved the drone along the respective body axis. r
I could never make sense of.
An MC vehicle in position mode does not roll or pitch - it move forward or left-right.
I agree it doesn't fit entirely and it's in my eyes impossible to find a naming that fully fits every single possible mode, that's why I favored consistency across drone remotes.
So you've made this very unintuitive except for fixed wing vehicles.
I disagree. For someone who never worked with drones before and has no reference from any other project or product you could argue the previous naming was equal as suitable. But this is clearly not the case. As I elaborated in #15949 (comment) people come with previous knowledge and or use a remote of some brand and the roll, pitch, yaw, throttle naming is the most popular and consistent one out in the hobby and industry. So it's not just me who got confused when joining PX4 why it needs to have different naming than everyone else, every time has to think twice about which axis it now is and keep a translation table in the comments but numerous other people I asked and found reference for in the code.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
After 5 years working with PX4 I still had to look up every time what x,y,z and r are linked to, so for me these new namings are massively more intuitive.
This pull request has been mentioned on Discussion Forum for PX4, Pixhawk, QGroundControl, MAVSDK, MAVLink. There might be relevant details there: https://discuss.px4.io/t/driving-backwards-with-a-boat-rover-in-manual-mode/25714/6 |
Describe problem solved by this pull request
Fixes #9331 and works towards a solution for part of #15874
Describe your solution
Rescale
manual_control_setpoint.z
which represents the throttle stick value from a range of [0,1] to [-1,1].Describe possible alternatives
I think for nicer usage in all the different modules it would be helpful to extend the
Sticks
class to provide the common scaling and gestures (is stick below minimum) from one single place.Test data / coverage
Not yet tested.
Additional context
This is also useful to be able to convert between RC modes (https://www.rc-airplane-world.com/rc-transmitter-modes.html) on the fly without having to recalibrate everything.